package in.co.codedoc.encrypt;

import java.util.Collection;

public class HashValue
{
	public HashValue(String text)
	{
		SetEncodedHash(MD5.Hash(text));
	}
	
	public HashValue(long[] longs)
	{
		SetEncodedHash(MD5.Hash(longs));
	}

	public HashValue(Collection<Long> longs)
	{
		SetEncodedHash(MD5.Hash(longs));
	}
	
	public HashValue(byte[] bytes)
	{
		SetEncodedHash(MD5.Hash(bytes));
	}
	
	public HashValue()
	{
		
	}
	
	public HashValue SetEncodedHash(String encodedHash)
	{
		this.encodedHash = encodedHash.toLowerCase();
		return this;
	}
	
	public String GetEncodedHash()
	{
		return encodedHash;
	}
	
	@Override
	public boolean equals(Object t)
	{
		if(t == null ||!(t instanceof HashValue))
		{
			return false;
		}
		
		HashValue that = (HashValue)t;
		
		return encodedHash.equalsIgnoreCase(that.encodedHash);
	}
	
	@Override
	public String toString()
	{
		return encodedHash;
	}
	
	@Override
	public int hashCode()
	{
		return encodedHash.hashCode();
	}
	
	private String encodedHash;
}
